<?php
/**
 * author : huhaiqin
 * time ： 2019-11-12 
 * feature ：基类控制器
 */
namespace Common\Controller;
use Think\Controller;

class BaseController extends Controller{

	public function _initialize(){
	}
	
    public function _del($m,$ids){
		if ( empty($ids) ) {
			_apiReturn(0, "请设置删除数据ID");
		}
		$map = array($m->getPk() => array('in', $ids));
		$lists = $m->where($map)->select();
		if($m->where($map)->delete()){ //删除本地数据库中的row
			_apiReturn(1, "删除成功");
		} else {
			_apiReturn(0, "删除失败",$m->_sql());
		}
	}
	
	public function _delbyuser($m,$ids,$uid){
		if ( empty($ids) ) {
			_apiReturn(0, "请设置删除数据ID");
		}
		$map = array($m->getPk() => array('in', $ids));
		$lists = $m->where($map)->select();
		if($uid){
			foreach($lists as $vo){
				if($vo['uid'] != $uid){
					_apiReturn(0, '有您没有权限删除的数据，无法删除', $data, $url);
				}
			}
		}
		if($m->where($map)->delete()){ //删除本地数据库中的row
			_apiReturn(1, "删除成功");
		} else {
			_apiReturn(0, "删除失败");
		}
	}

	
	function _empty(){
		header("HTTP/1.0 404 Not Found");
		$this->display('Common@Public:404');
		die();
	}
}